package ph.com.gs3.formalistics.model.valueobjects.business.document;

import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;

import ph.com.gs3.formalistics.view.valueobjects.parsers.DateUtilities;

public class DocumentStub implements Comparable<DocumentStub>, Serializable {

	private static final long serialVersionUID = -2305668172620869375L;

	public String dateUpdated;
	public String webId;
	public String formWebId;

	@Override
	public String toString() {
		return "Document Id: " + webId + " Form Id: " + formWebId + " Updated: " + dateUpdated;
	}

	@Override
	public int compareTo(DocumentStub another) {
		try {
			Date thisStubDate = DateUtilities.parseToServerDate(dateUpdated);
			Date anotherStubDate = DateUtilities.parseToServerDate(another.dateUpdated);

			// descending order
			return anotherStubDate.compareTo(thisStubDate);
		} catch (ParseException e) {
			return 0;
		}
	}

}
